#include <vector>
using namespace std;
class Solution
{
public:

    //二分查找 时间复杂度O(logn)
    int findMin1(vector<int> &nums)
    {
        int left = 0, right = nums.size() - 1;
        int mid = 0;

        // 只用left和mid对应的值比较，或用right和mid的值比较
        while (left < right)
        {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[right])
            {
                left = mid + 1; //
            }
            else
                right = mid; //
        }
        return nums[left];
    }

    //遍历数组 时间复杂度O(n)
    int findMin2(vector<int> &nums)
    {
        if(0 == nums.size())
        {
            return 0;
        }
        int res = 0;
        for(int i = 1;i<nums.size();++i)
        {
            if(nums[i]<nums[i-1]) //根据数据的排序规则判断出最小的数
            {
                res = nums[i];
            }
        }
        return res;
    }
};